﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AvantGameMachine.Events;
using AvantGameMachine.Input.Keyboard;

namespace AvantGameMachine.Graphics.InternalObjects
{
    class DebugCamera : Camera, ILocalEventReceiver
    {
        public DebugCamera()
        {
            AGMPlatform.EManager.RegisterLocalReceiver(this, EventTypes.EVENT_TYPE_KEY);
        }

        public override void Update()
        {
            base.Update();
        }

        public void ReceiveLocalEvent(Event _event)
        {
            switch (_event.Type)
            {
                case EventTypes.EVENT_TYPE_KEY:
                    switch (((KeyboardEventData)_event.Data).Key)
                    {
                        case Keys.KEY_w:
                            RotateEyeX((float)(Math.PI / 32));
                            break;
                        case Keys.KEY_x:
                            RotateEyeX((float)(Math.PI / -32));
                            break;
                        case Keys.KEY_a:
                            RotateEyeY((float)(Math.PI / 32));
                            break;
                        case Keys.KEY_d:
                            RotateEyeY((float)(Math.PI / -32));
                            break;
                        case Keys.KEY_q:
                            RotateEyeZ((float)(Math.PI / 32));
                            break;
                        case Keys.KEY_e:
                            RotateEyeZ((float)(Math.PI / -32));
                            break;
                        case Keys.KEY_f:
                            MoveRight(-1.0f);
                            break;
                        case Keys.KEY_h:
                            MoveRight(1.0f);
                            break;
                        case Keys.KEY_t:
                            MoveBackward(1.0f);
                            break;
                        case Keys.KEY_g:
                            MoveBackward(-1.0f);
                            break;

                        /*
                        case 108: // (l) It has a special case when the rotLZ becomes 
                            // less than -15 the screen is viewed from the opposite side
                            // therefore this if statement below does not allow 
                            // rotLz be less than -15
                            this.eye.Z -= 2.0f;
                            break;
                        case 76:    // L
                            this.eye.Z += 2.0f;
                            break;*/
/*                        case 98:    // b        // Rotates on x axis by -90 degree
                            rotX -= 90.0f;
                            break;
                        case 66:    // B        // Rotates on y axis by 90 degree
                            rotX += 90.0f;
                            break;
                        case 110:    // n        // Rotates on y axis by -90 degree
                            rotY -= 90.0f;
                            break;
                        case 78:    // N        // Rotates on y axis by 90 degree
                            rotY += 90.0f;
                            break;
                        case 109:    // m        // Rotates on z axis by -90 degree
                            rotZ -= 90.0f;
                            break;
                        case 77:    // M        // Rotates on z axis by 90 degree
                            rotZ += 90.0f;
                            break;
                        case 111:    // o        // Resets all parameters
                        case 80:    // O        // Displays the cube in the starting position
                            rotation = false;
                            X = Y = 0.0f;
                            Z = 0.0f;
                            rotX = 0.0f;
                            rotY = 0.0f;
                            rotZ = 0.0f;
                            rotLx = 0.0f;
                            rotLy = 0.0f;
                            rotLz = 0.0f;
                            Gl.glMatrixMode(Gl.GL_MODELVIEW);
                            Gl.glLoadIdentity();
                            Glu.gluLookAt(rotLx, rotLy, zconst + rotLz,
                                0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
                            break;*/
                    }
                    break;
            }
        }
    }
}
